import * as Cesium from "cesium";
import GosViewer from "modules/viewer";
import Roaming from "modules/roaming";
import { Position, CoordTransform } from "modules/tool";
export { default as Imagery, ImageryType } from "modules/imagery";

class CGos {
    constructor(root, options) {
        this._viewer = new GosViewer(root, options);
        this._layers = {
            model: [],
        };
    }
    enableRoaming(flag) {
        var keyboardRoaming = Roaming.Keyboard.getInstance(this._viewer);
        if (flag) {
            keyboardRoaming.start();
        } else {
            keyboardRoaming.stop();
        }
    }
    flyTo(position) {
        let viewer = this._viewer;
        if (position instanceof Position) {
            var center = Cesium.Cartesian3.fromDegrees(position.longitude, position.latitude, position.height || 400);
            viewer.camera.flyTo({
                destination: center,
                orientation: {
                    heading: Cesium.Math.toRadians(position.heading),
                    pitch: Cesium.Math.toRadians(position.pitch),
                    roll: Cesium.Math.toRadians(position.roll),
                },
            });
        } else {
            throw new Cesium.DeveloperError("params is not valid Position");
        }
    }
    addModel(uri, position, name) {
        var viewer = this._viewer;
        viewer.entities.add({
            name: name || "默认模型",
            position: CoordTransform.WGS84ToCartesian(position),
            model: {
                uri: uri,
            },
        });
    }
    addPrimitive() {}
    addEntity() {}
}
export default CGos;
